<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js">
    </script>

    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">

    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>

</head>
<body>
<br>
<div class="container">
    <div class="row">
        <table class="table  mytable table-bordered">
            <thead>
            <tr>
                <td>日期</td>
                <td>分类</td>
                <td>金额</td>
                <td>备注</td>
                <td>操作</td>
            </tr>
            </thead>
            <tbody>
            <tr th:each="moneyList:${moneyList}">
                <td th:text="${#dates.format(moneyList.createtime,'yyyy-MM-dd')}">2020-08-18 12:12:12</td>
                <td th:text="${moneyList.moneytag.moneytag}">2020-08-18 12:12:12</td>
                <td th:text="${moneyList.money}">2020-08-18 12:12:12</td>
                <td th:text="${moneyList.remark}">2020-08-18 12:12:12</td>
                <td>
                    <a th:href="@{'/user/updateMoney/'+${moneyList.id}}" >
                        <button class="btn btn-success" >修改</button>
                    </a>
                    <a id="deleteBtn">
                        <button class="btn btn-warning" id="dayid" th:value="${moneyList.id}" th:onclick="'deleteMoney('+${moneyList.id}+')'" >删除</button>
                    </a>
                </td>
            </tr>
            </tbody>
        </table>
        <ul class="pagination">
            <li><a th:href="@{'/user/money?pageNum='+${currPage -1}}">&laquo;</a></li>
            <li th:each="pageNum:${pages}">
                <a th:href="@{'/user/money?pageNum='+${pageNum}}"th:classappend="${pageNum==currPage}?'active'"th:text="${pageNum}">1</a>
            </li>
            <li><a th:href="@{'/user/money?pageNum='+${currPage+1}}">&raquo;</a></li>
        </ul>
    </div>
</div>


<!--删除-->
<script>
    function deleteMoney(moneyid){
        var result = confirm("确认删除？")
        if (result){
            //删除

            $.ajax({
                url:"[(@{/user/deleteMoney})]",
                data:{"moneyid":moneyid},
                type:"post",
                success:function (measure) {
                    if (measure == "1"){
                        //删除成功
                        alert("删除成功")
                        window.location.href="[(@{/user/money})]"
                    }
                }
            })
        }
    }


</script>

</body>
</html>